package com.zjx;

import com.zjx.Service.WelcomeService;

import com.zjx.aop.HelloService;
import com.zjx.bean.TestChangeMethod;
import com.zjx.bean.UserManager;
import com.zjx.circle.A;
import com.zjx.controller.WelcomeController;
import com.zjx.dao.Impl.BoyFriend;
import com.zjx.entity.User;
import com.zjx.entity.factory.UserFactoryBean;
import com.zjx.listener.AppEventPublisher;
import com.zjx.listener.MessageEvent;
import com.zjx.processor.factory.MybeanFactory;
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zjx
 * @create 2020-03-22 17:27
 */
@Configuration
@ComponentScan({"com.zjx.processor","com.zjx.bean"})
public class Entrance {
	public static void main(String[] args) {
		System.out.println("Hello World!");
		String xmlPath ="//Volumes/手握日月星辰/spring-framework/spring-framework-5.2.0.RELEASE/springdemo/src/main/resources/spring/spring-tx-config.xml";
		ApplicationContext applicationContext = new FileSystemXmlApplicationContext(xmlPath);
		//UserManager userManager =(UserManager)applicationContext.getBean("userManager");
		// System.out.println(userManager);
		//得到beanFactory创建的对象:
//		User user4a=(User) applicationContext.getBean("userFactoryBean");
//		User user4b=(User)applicationContext.getBean("userFactoryBean");
//		System.out.println("factorybean创建的对象"+user4a);
//		System.out.println("factorybean创建的对象"+user4b);
//
//		FileFactory fileFactory = new FileFactory();
//		IFileOperator iFileOperator = fileFactory.getbyType("2");
//		ApplicationContext ctx = new ClassPathXmlApplicationContext("beans2.xml");

	}

//		public static void main(String[] args) throws Exception {
//			//为什么这个东西有的人叫上下文，有的人叫容器呢？ 上下文 = 容器
//		ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Entrance.class);
////		String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
////		for(String beanDefinitionName:beanDefinitionNames){
////			System.out.println(beanDefinitionName);
////
////		}
////		WelcomeController welcomeController =(WelcomeController)applicationContext.getBean("welcomeController");
////		welcomeController.handRequest();
////		User user5=(User)applicationContext.getBean("user5");
////		System.out.println("CustomizedBeanDefinitionRegistryPostProcessor创建的对象:"+user5);
//		//监听器开始测试了
//
////		AppEventPublisher eventPublisher = applicationContext.getBean(AppEventPublisher.class);
////		MessageEvent message = new MessageEvent("发送短信");
////		eventPublisher.publish(message);
//		//不支持循环依赖多例测试
//			HelloService helloService=  applicationContext.getBean(HelloService.class);
//			helloService.sayHello("zzzjx");
////			MybeanFactory bean = applicationContext.getBean(MybeanFactory.class);
////			A object = bean.getObject();
////		System.out.print(ossAli);
//	}
//	public static void main(String[] args) {
//		ApplicationContext bf = new FileSystemXmlApplicationContext("//Volumes/手握日月星辰/spring-framework/spring-framework-5.2.0.RELEASE/springdemo/src/main/resources/spring/spring-config.xml");
//		TestChangeMethod testChangeMethod = (TestChangeMethod) bf.getBean("testChangeMethod");
//		testChangeMethod.getMethod();
//	}
}
